# Lucid - Panethnic Identity -----------------------------------------------
A <- designMatrices(resp=lucid_panethnic)$A
A1 <- A
dimnames(A1)[[1]] <- colnames(lucid_panethnic)
A1[1,,] = A1[4,,]
A1[2,,] = A1[5,,]
A1[3,,] = A1[6,,]

lucid_panethnic_m <- tam.mml(lucid_panethnic,
                        group = lucid_language_group,
                        irtmodel = "PCM",
                        beta.fixed = cbind(c(1:3), 
                                           1, c(0, 0, 0)),
                        A = A1)

lucid_panethnic_m <- tam.mml(lucid_panethnic,
                        group = lucid_language_group,
                        irtmodel = "PCM",
                        beta.fixed = cbind(c(1:3), 
                                           1, c(0, 0, 0)),
                        A = A1,
                        xsi.fixed = cbind(c(1:10), 
                                          lucid_panethnic_m$xsi.fixed.estimated[11:20,2]))

lucid_panethnic_m2 <- tam.mml(lucid_panethnic,
                         group = lucid_language_group,
                         irtmodel = "PCM",
                         beta.fixed = cbind( c(1:3), 
                                             1, c(0, 0, 0)))

lucid_panethnic_lr <- IRT.compareModels(lucid_panethnic_m,
                                        lucid_panethnic_m2)

# Lucid - Immigration Opinion -----------------------------------------------
A <- designMatrices(resp=lucid_immigration)$A
A1 <- A
dimnames(A1)[[1]] <- colnames(lucid_immigration)
A1[1,,] = A1[4,,]
A1[2,,] = A1[5,,]
A1[3,,] = A1[6,,]

lucid_immigration_m <- tam.mml(lucid_immigration,
                      group = lucid_language_group,
                      irtmodel = "PCM",
                      beta.fixed = cbind(c(1:3), 
                                         1, c(0, 0, 0)),
                      A = A1)

lucid_immigration_m <- tam.mml(lucid_immigration,
                      group = lucid_language_group,
                      irtmodel = "PCM",
                      beta.fixed = cbind(c(1:3), 
                                         1, c(0, 0, 0)),
                      A = A1,
                      xsi.fixed = cbind(which(lucid_immigration_m$xsi.fixed.estimated[,2] == 0), 
                                        which(lucid_immigration_m$xsi.fixed.estimated[,2] != 0)))

lucid_immigration_m2 <- tam.mml(lucid_immigration,
                       group = lucid_language_group,
                       irtmodel = "PCM",
                       beta.fixed = cbind( c(1:3), 
                                           1, c(0, 0, 0)))

lucid_immigration_lr <- IRT.compareModels(lucid_immigration_m,
                             lucid_immigration_m2)

# Lucid - Anti-Trans Sentiment -----------------------------------------------
A <- designMatrices(resp=lucid_attp)$A
A1 <- A
dimnames(A1)[[1]] <- colnames(lucid_attp)
A1[1,,] = A1[8,,]
A1[2,,] = A1[9,,]
A1[3,,] = A1[10,,]
A1[4,,] = A1[11,,]
A1[5,,] = A1[12,,]
A1[6,,] = A1[13,,]
A1[7,,] = A1[14,,]

lucid_attp_m <- tam.mml(lucid_attp,
                     group = lucid_language_group,
                     irtmodel = "PCM",
                     beta.fixed = cbind(c(1:3), 
                                        1, c(0, 0, 0)),
                     A = A1)

lucid_attp_m <- tam.mml(lucid_attp,
                     group = lucid_language_group,
                     irtmodel = "PCM",
                     beta.fixed = cbind(c(1:3), 
                                        1, c(0, 0, 0)),
                     A = A1,
                     xsi.fixed = cbind(which(lucid_attp_m$xsi.fixed.estimated[,2] == 0), 
                                       which(lucid_attp_m$xsi.fixed.estimated[,2] != 0)))

lucid_attp_m2 <- tam.mml(lucid_attp,
                      group = lucid_language_group,
                      irtmodel = "PCM",
                      beta.fixed = cbind( c(1:3), 
                                          1, c(0, 0, 0)))

lucid_attp_lr <- IRT.compareModels(lucid_attp_m,
                            lucid_attp_m2)


